﻿<UserControl x:Class="Microsoft.Research.ScientificWorkflow.ManagementStudioControls.RegistryManagerModule.ActivitiesTree"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Name="activityLeftPaneView" AutomationProperties.AutomationId="categoryLeftPaneView" Height="200"
    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
    <UserControl.Resources>
        <Style x:Key="TreeViewStyle" TargetType="{x:Type TreeView}">
            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
            <Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Padding" Value="1"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TreeView}">
                        <Border SnapsToDevicePixels="true" x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                            <ScrollViewer Focusable="false" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" CanContentScroll="false" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" Template="{DynamicResource ScrollViewerControlTemplate3}">
                                <ItemsPresenter/>
                            </ScrollViewer>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <HierarchicalDataTemplate x:Key="ParentActivityTemplate" ItemsSource="{Binding Path=Children}">
            <Grid PreviewMouseDown="OnGridPreviewMouseDown">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="21.5"/>
                    <ColumnDefinition Width="*" MinWidth="26.098"/>
                </Grid.ColumnDefinitions>
                <Image Grid.ColumnSpan="1" Width="16" HorizontalAlignment="Center" VerticalAlignment="Center" Height="16">
                    <Image.Source>
                        <Binding Path="ItemIcon"/>
                    </Image.Source>
                </Image>
                <TextBlock Grid.Column="1" Margin="1,0,0,0" Text="{Binding Path=Label}" AutomationProperties.AutomationId="{Binding Path=Name}"></TextBlock>
            </Grid>
        </HierarchicalDataTemplate>
    </UserControl.Resources>
    <Grid HorizontalAlignment="Stretch">
        <TreeView HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"
                  Style="{DynamicResource TreeViewStyle}"
                  x:Name="activityTreeview"  SelectedItemChanged="OnSelectedItemChanged"
                  ItemContainerStyle="{DynamicResource TreeViewItemStyleCustomImage}" ItemTemplate="{StaticResource ParentActivityTemplate}"
                  ItemsSource="{Binding Path=LeftPaneTreeItems}"/>
    </Grid>
</UserControl>
